package com.pj.point.util.view;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ListAdapter;
import android.widget.ListView;

public class LIstViewUtil {
    public static void setHeight(ListView listView)
    {
        ListAdapter adapter = listView.getAdapter();
        if (adapter==null)
            return;
        int height = 0;
        for (int i = 0,len = adapter.getCount(); i < len; i++) {
            View view = adapter.getView(i, null, listView);
            view.measure(0,0);
            height += view.getMeasuredHeight();
        }

        ViewGroup.LayoutParams params = listView.getLayoutParams();
        params.height = height + (adapter.getCount()-1) * listView.getDividerHeight();
        listView.setLayoutParams(params);
    }
}
